package com.ophiux.common.tools.util;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;

public class FileCoinUtil {
    /**
     * fil 转 官网最小值
     *
     * @param fil
     * @return
     */
    public static BigInteger toAttoFIL(BigDecimal fil) {
        BigDecimal decimal = fil.multiply(BigDecimal.TEN.pow(18));
        return decimal.toBigInteger();
    }

    /**
     * 官网最小值 转 fil
     * @param attoFIL
     * @return
     */
    public static BigDecimal fromAttoFIL(BigInteger attoFIL) {
        BigDecimal bigDecimal = new BigDecimal(attoFIL);
        return bigDecimal.divide(BigDecimal.TEN.pow(18), 18, RoundingMode.DOWN);
    }

    public static BigInteger toNanoFIL(BigDecimal fil) {
        BigDecimal decimal = fil.multiply(BigDecimal.TEN.pow(9));
        return decimal.toBigInteger();
    }

    public static Long fromNanoFIL(BigInteger attoFIL) {
        return attoFIL.divide(BigInteger.TEN.pow(9)).longValue();
    }
}
